package com.msconfig.mvp.view.fragment;

/*
 * author: caojunhao
 * date  : 2020/4/28
 * desc  :
 */

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.geo.msconfig.R;
import com.msconfig.device.DeviceManage;
import com.msconfig.event.NullEvent;
import com.msconfig.io.ConnectListener;
import com.msconfig.mvp.view.activity.base.BaseMvpActivity;
import com.msconfig.mvp.view.activity.base.BaseMvpFragment;
import com.msconfig.mvp.view.activity.base.BasePresenter;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.List;

public class SetUpPageFragment extends BaseMvpFragment implements View.OnClickListener{
    private LinearLayout llEquipmentCommunicationSetup;
    private LinearLayout llSetupGprs;
    private LinearLayout llSetupWifi;
    private LinearLayout llSetupSurveyStation;
    private LinearLayout llSetupTransformation;
    private LinearLayout llSetupOther;
    private LinearLayout llSetupDebug;
    private LinearLayout llSetupAbout;
    public static SetUpPageFragment newInstance() {
        Bundle args = new Bundle();
        SetUpPageFragment fragment = new SetUpPageFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.layout_fragment_setup;
    }

    @Override
    protected void initView(View view) {
        llEquipmentCommunicationSetup=view.findViewById(R.id.ll_equipment_communication_setup);
        llSetupGprs = (LinearLayout)view.findViewById( R.id.ll_setup_gprs );
        llSetupWifi = (LinearLayout)view.findViewById( R.id.ll_setup_wifi );
        llSetupSurveyStation = (LinearLayout)view.findViewById( R.id.ll_setup_survey_station );
        llSetupTransformation = (LinearLayout)view.findViewById( R.id.ll_setup_transformation );
        llSetupOther = (LinearLayout)view.findViewById( R.id.ll_setup_other );
        llSetupDebug = (LinearLayout)view.findViewById( R.id.ll_setup_debug );
        llSetupAbout = (LinearLayout)view.findViewById( R.id.ll_setup_about);
    }

    @Override
    protected void initListener(View view) {
        llEquipmentCommunicationSetup.setOnClickListener(this);
        llSetupGprs.setOnClickListener(this);
        llSetupWifi.setOnClickListener(this);
        llSetupSurveyStation.setOnClickListener(this);
        llSetupTransformation.setOnClickListener(this);
        llSetupOther.setOnClickListener(this);
        llSetupDebug.setOnClickListener(this);
        llSetupAbout.setOnClickListener(this);
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.ll_equipment_communication_setup:
                ((BaseMvpActivity)getActivity()).goToNextFragment(this, EquipmentCommunicationSetupFragment.newInstance());
                break;
            case R.id.ll_setup_gprs:
                ((BaseMvpActivity)getActivity()).goToNextFragment(this, SetupGprsFragment.newInstance());
                break;
            case R.id.ll_setup_wifi:
                ((BaseMvpActivity)getActivity()).goToNextFragment(this, SetupWifiFragment.newInstance());
                break;
            case R.id.ll_setup_survey_station:
                ((BaseMvpActivity)getActivity()).goToNextFragment(this, SetupSurveyStationFragment.newInstance());
                break;
            case R.id.ll_setup_transformation:
                ((BaseMvpActivity)getActivity()).goToNextFragment(this, SetupTransformationFragment.newInstance());
                break;
            case R.id.ll_setup_other:
                ((BaseMvpActivity)getActivity()).goToNextFragment(this, SetupOtherFragment.newInstance());
                break;
            case R.id.ll_setup_debug:
                if(!DeviceManage.getInstance().isConnected()){
                    Toast.makeText(getContext(),R.string.toast_none_connect, Toast.LENGTH_SHORT).show();
                    return;
                }
                ((BaseMvpActivity)getActivity()).goToNextFragment(this, SetupDebugFragment.newInstance());
                break;
            case R.id.ll_setup_about:
                ((BaseMvpActivity)getActivity()).goToNextFragment(this, SetupAboutFragment.newInstance());
                break;


        }
    }

    //目前这里只是为了实现eventbus
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void haveNull(NullEvent event) {
    }

    @Override
    protected void createPresenter(List<BasePresenter> mPresenters) {

    }
}
